package com.zmn.plat.services.impl.channel.generalproduct;

import com.zmn.plat.model.entity.channel.generalproduct.ChannelGeneralProductSwitch;
import com.zmn.plat.model.entity.channel.generalproduct.ChannelGeneralProductSwitchQuery;
import com.zmn.plat.persistence.interfaces.channel.generalproduct.ChannelGeneralProductSwitchDao;
import com.zmn.plat.services.interfaces.channel.generalproduct.ChannelGeneralProductSwitchService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ChannelGeneralProductSwitchServiceImpl implements ChannelGeneralProductSwitchService {

    @Resource
    ChannelGeneralProductSwitchDao channelGeneralProductSwitchDao;

    @Override
    public ChannelGeneralProductSwitch findByKey(Integer relateId) {
        return channelGeneralProductSwitchDao.findByKey(relateId);
    }

    @Override
    public ChannelGeneralProductSwitch findByChannelIdAndServCategId(Integer channelId, Integer servCategId) {
        return channelGeneralProductSwitchDao.findByChannelIdAndServCategId(channelId, servCategId);
    }

    @Override
    public List<ChannelGeneralProductSwitch> listByChannelId(Integer channelId) {
        return channelGeneralProductSwitchDao.listByChannelId(channelId);
    }

    @Override
    public List<ChannelGeneralProductSwitch> listByQuery(ChannelGeneralProductSwitchQuery query) {
        return channelGeneralProductSwitchDao.listByQuery(query);
    }

    @Override
    public List<ChannelGeneralProductSwitch> listAll() {
        return channelGeneralProductSwitchDao.listAll();
    }

    @Override
    @Cacheable(cacheNames = "redis5m", key = "'servcategId:channel:'+#p0+#p1", unless = "#result == null")
    public List<Integer> listServCateIdByChannelAndStatus(Integer channelId, int status) {

        return channelGeneralProductSwitchDao.listServCateIdByChannelAndStatus(channelId, status);
    }

    @Override
    public Integer updateByKey(ChannelGeneralProductSwitch channelGeneralProductSwitch) {
        return channelGeneralProductSwitchDao.updateByKey(channelGeneralProductSwitch);
    }

    @Override
    public Integer insert(ChannelGeneralProductSwitch channelGeneralProductSwitch) {
        return channelGeneralProductSwitchDao.insert(channelGeneralProductSwitch);
    }

    @Override
    public Integer insertBatch(List<ChannelGeneralProductSwitch> channelGeneralProductSwitches) {
        return channelGeneralProductSwitchDao.insertBatch(channelGeneralProductSwitches);
    }

    @Override
    public Integer deleteByKey(Integer relateId) {
        return channelGeneralProductSwitchDao.deleteByKey(relateId);
    }

    @Override
    public Integer deleteByKeys(List<String> ids) {
        return channelGeneralProductSwitchDao.deleteByKeys(ids);
    }

    @Override
    public Integer deleteByChannelId(Integer channelId) {
        return channelGeneralProductSwitchDao.deleteByChannelId(channelId);
    }

    @Override
    public void copy(Integer originalChannelId, int targetChannelId, String operator) {

        channelGeneralProductSwitchDao.copy(originalChannelId, targetChannelId, operator);
    }
}